package com.ds.controller.restful;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.ds.core.base.AbstractController;
import com.ds.core.exception.BizException;
import com.ds.orm.model.WebsiteConf;
import com.ds.service.WebsiteConfService;

/**
 * <p>
 * 业务层控制器
 * </p>
 *
 * @author Du
 * @since 2017-11-19
 */
@RestController
@RequestMapping("/biz")
@Api(value = "获取主页参数接口", description = "获取主页参数接口")
public class BizController extends AbstractController {
	@Autowired
	WebsiteConfService websiteConfService;

	@ApiOperation(value = "主页基本参数")
	@RequestMapping(value = "{url}")
	public Object bizConf(@PathVariable String url, ModelMap modelMap) {
		WebsiteConf websiteConf = websiteConfService.queryByUrl(url);
		if (websiteConf == null) {
			throw new BizException("资源无效");
		} else {
			modelMap.put("data", websiteConf);
		}
		return setSuccessModelMap(modelMap);
	}
}
